package org.ilovecode.display {
	import org.ilovecode.Utilities;
	
	/**
	 * ...
	 * @author Vjekoslav Ratkajec
	 */
	public class Apartment {
		
		private var _id:int;
		private var _code:String;
		private var _building:String;
		private var _state:String;
		private var _floor:String;
		private var _numRooms:String;
		private var _area:String;
		private var _roomList:Array;
		private var _thumbURL:String;
		private var _imageURL:String;
		
		public function Apartment(id:int, code:String, building:String, state:String, floor:String, numRooms:String, area:Number, roomList:Array, thumbURL:String, imageURL:String) {
			_id = id;
			_code = code;
			_building = building;
			_state = state;
			_floor = floor;
			_numRooms = numRooms;
			_area = area.toFixed(2);
			_roomList = roomList;
			_thumbURL = thumbURL;
			_imageURL = imageURL;
		}
		
		public function getTotalArea():Number {
			var totalArea:Number = 0;
			for each (var room:Object in roomList) {
				totalArea += Number(room.area);
			}
			
			return totalArea;
		}
		
		//{ region Getters
		
		public function get id():int {
			return _id;
		}
		
		public function get code():String {
			return _code;
		}
		
		public function get name():String {
			var index:int = code.lastIndexOf(".", code.length - 2);
			var apartmentName:String = code.slice(index + 1, code.length - 1);
			return apartmentName;
		}
		
		public function get building():String {
			return _building;
		}
		
		public function get state():String {
			return _state;
		}
		
		public function get floor():String {
			return _floor;
		}
		
		public function get numRooms():String {
			return _numRooms;
		}
		
		public function get area():String {
			return _area;
		}
		
		//List of objects with properites name and area
		public function get roomList():Array {
			return _roomList;
		}
		
		public function get thumbURL():String {
			return _thumbURL;
		}
		
		public function get imageURL():String {
			return _imageURL;
		}
		
		//} endregion
		
	}

}